<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子18-ES6/7常用语法介绍</title>
    </head>
    <body>
        <pre>
            <code>
                // 例子18

                function push(array, ...items) {
                    items.forEach(function(item) {
                      array.push(item);
                    });
                }

                let a = [];
                push(a, 1, 2, 3);
                console.log(a); // [1, 2, 3]

                //--------------------------------------------------------------------------

                function f(a, ...b, c) {}; // Uncaught SyntaxError: Rest parameter must be last formal parameter
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/18.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>